package mbalib.docviewer
{
	import flash.display.*;
	import flash.events.*;
	
	public class main extends Sprite
	{
		private var _reader:Reader;
		
		public function main()
		{
			this.addEventListener(Event.ENTER_FRAME, this.checkLoaded);
			return;
		}// end function
		
		private function init() : void
		{
			stage.showDefaultContextMenu = false;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			//url参数
			var _loc_1:* = this.loaderInfo.parameters;
			//添加阅读器
			this._reader = new Reader();
			this.addChild(this._reader);
			var _loc_2:String = "http://doc.mbalib.com/read";
			if (_loc_1["docurl"])
			{
				_loc_2 = _loc_1["docurl"];
			}
			var _loc_3:String = "b6a75a641bb3a509a3241e8fdc3a4398";
			if (_loc_1["docid"])
			{
				_loc_3 = _loc_1["docid"];
			}
			this._reader.fpn = 1;//第一页 
			if (int(_loc_1["fpn"]))
			{
				this._reader.fpn = int(_loc_1["fpn"]);
			}
			this._reader.npn = 5;
			if (int(_loc_1["npn"]))
			{
				this._reader.npn = int(_loc_1["npn"]);
			}
			var _loc_4:* = 30;
			if (int(_loc_1["total"]))
			{
				_loc_4 = int(_loc_1["total"]);
			}
		 this._reader.docURL = _loc_2.replace(/(\/)+$/, "") + "/" + _loc_3 + "?tn=" + _loc_4 + "&";
		 
			return;
		}// end function
		
		private function checkLoaded(event:Event = null) : void
		{
			if (stage.stageWidth > 0 && stage.stageHeight > 0)
			{
				this.removeEventListener(Event.ENTER_FRAME, this.checkLoaded);
				this.init();
			}
			return;
		}// end function
		
	}
}
